//
//  EGMotionLaunchViewController.m
//  MotionLaunchDemo
//
//  Created by 程登伟 on 16/9/14.
//  Copyright © 2016年 程登伟. All rights reserved.
//

#import "EGMotionLaunchViewController.h"
#import "EGMotionLaunchView.h"

#define EGSCREENWIDTH [UIScreen mainScreen].bounds.size.width
#define EGSCREENHEIGHT [UIScreen mainScreen].bounds.size.height

@interface EGMotionLaunchViewController ()

@property (nonatomic, strong) UIView *backgroundV;
@property (nonatomic, strong) UILabel *noticeLabel;
@property (nonatomic, strong) EGMotionLaunchView *motionView;


@end

@implementation EGMotionLaunchViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor colorWithRed:246/255.0 green:246/255.0 blue:246/255.0 alpha:1];
    
    [self setupSubviews];
    
}




-(void)setupSubviews{
//    EGMotionItemView *eg = [[EGMotionItemView alloc] initWithFrame:CGRectMake(0, 10, 20, 30)];
    
    
    self.backgroundV = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.backgroundV.backgroundColor = [UIColor clearColor];
    [self.view addSubview:self.backgroundV];
    
    // back
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    backButton.frame = CGRectMake(20, 30, 50, 30);
    [backButton setTitle:@"关闭" forState:UIControlStateNormal];
    [backButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(closeMotionVC) forControlEvents:UIControlEventTouchUpInside];
    [self.backgroundV addSubview:backButton];
    
    
    // motionView
    CGRect motionRect = CGRectMake(0, EGSCREENHEIGHT - EGSCREENWIDTH - 80, EGSCREENWIDTH, EGSCREENWIDTH);
    self.motionView = [EGMotionLaunchView showMotionViewWithFrame:motionRect success:^(NSString *motionPassword) {
        NSLog(@"pas = %@",motionPassword);
    } faild:^(NSString *faildMessage) {
        NSLog(@"errorMes = %@",faildMessage);
    }];
    [self.view addSubview:self.motionView];
    
    
    
    // notice
    self.noticeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, EGSCREENHEIGHT - EGSCREENWIDTH - 80 - 50, EGSCREENWIDTH, 30)];
    [self.noticeLabel setText:@"输入您的手势"];
    self.noticeLabel.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:self.noticeLabel];
    
    // forget
    UIButton *forgetButton = [UIButton buttonWithType:UIButtonTypeCustom];
    forgetButton.frame = CGRectMake((EGSCREENWIDTH - 80)/2.0, EGSCREENHEIGHT - 80, 80, 30);
    [forgetButton setTitle:@"忘记密码" forState:UIControlStateNormal];
    [forgetButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    forgetButton.titleLabel.font = [ UIFont systemFontOfSize:13];
    [forgetButton addTarget:self action:@selector(gotgetAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:forgetButton];
}


-(void)closeMotionVC{
    
    [self dismissViewControllerAnimated:YES completion:nil];
    
}

-(void)gotgetAction{
    
    [self closeMotionVC];
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
